package com.ztr.phone;

public class PhoneJM {
    private static String phone = "13488889999";
    private static String idCard = "4350481200001204519";

    public static void main(String[] args) {
        // 手机号加密：134****9999 中间四位数
        String phoneJM = phone.replaceAll("(\\d{3})\\d{4}(\\d{4})", "$1****$2");
        // 身份证加密：前六后五，其余都加密 435048********04519
        String idCardJM = idCard.replaceAll("(\\d{6})\\d{8}(\\w{4})", "$1********$2");
        //身份证加密：前三后四，其余都加密 435************4519
//        String idCardJM = idCard.replaceAll("(?<=\\w{3})\\w(?=\\w{4})", "*");
        System.out.println("phone: " + phoneJM);
        System.out.println("idCard: " + idCardJM);
    }
}
